package{
	import com.PQLoad.PQLoader;
	import com.tools.Tip;

	public class ConfigParsing{
		/**配置路径**/
		private var url:String;
		/**资源列表**/
		private var resList:Array;
		/**配置列表**/
		private var configList:Array;
		/**编辑器**/
		public var edit:Editor;
		public function ConfigParsing(){
			init();
		}
		public function init():void{
			edit=new Editor();
			resList=[];
			configList=[];
		}
		/**载入列表**/
		public function loadConfig(_url:String):void{
			url=_url;
			PQLoader.load(url,{onComplete:configLoaded});
		}
		/**处理配置数据**/
		private function configLoaded(...args):void{
			var xml:XML=PQLoader.getXml("config/config.xml");
			for each(var ixml:XML in xml.item){
				resList.push(ixml.@res);
				configList.push({res:ixml.@res,x:parseInt(ixml.@x),y:parseInt(ixml.@y)});
			}
			if(resList.length<1)return;
			PQLoader.loadList(resList,{onComplete:resLoaded,onProgress:progress});
		}
		private function resLoaded(...args):void{
			Tip.showTip("配置载入完毕");
			edit.createView(configList);
		}
		private function progress(...args):void{
			
		}
	}
}